Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@discordia/framework

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discordia/framework

The main discordia framework

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45
increased by1025%
Maintainers
1
Weekly downloads
 
Created
Source
  • Installation
  • Basic Example
  • Usage
  • Testing

Note: Some of the links in this README file work better on the documentation site

Installation

Discordia instantiates and starts Discord bots using the @discordia/framework module.

# install the module using npm
npm install @discordia/framework

# install the module using yarn
yarn add @discordia/framework

Basic Example

const DiscordiaFramework = require('@discordia/framework');
// actions is an array of DiscordiaAction objects
const actions = require('./actions');
const options = {
  name: 'myBot',
  caseSensitiveName: false,
  missingCommandMessage: 'The command you tried to send was not available',
  help: 'You should probably configure a useful help message or leave the default',
};

const myBot = new DiscordiaFramework('DISCORD_BOT_TOKEN', actions, options);

// Set up the event listeners and log the bot in using the provided token
myBot.start();

Usage

Every Discordia framework is made of three pieces: a token, an array of actions, and a set of optional options.

Token

String

Your private Discord bot token. The token for your bot should be located at https://discordapp.com/developers/applications/{client-id}/bot (replace {client-id} with the Client ID of your Discord application) in a hidden field that you can reveal by clicking "Click to Reveal Token". This guide is a useful one for making a new Discord bot if you have not done so before. Follow that guide through step #4 to make your bot and get a link to invite it to a server.

⚠️This token is a sensitive piece of information - do not commit it with your source code and regenerate it if it ever becomes compromised⚠️

Actions

Array[DiscordiaAction]

An array of DiscordiaAction objects. See our guide on how to use the @discordia/action module to create your own actions and/or install them from third party modules.

Options

Object

The options object is prepopulated with overrideable defaults. More in-depth explanations of the available options are below.

OptionDefault
nameundefined
caseSensitiveNamefalse
missingCommandMessage"The command you typed is not available 🙁"
help@discordia/default-help

name

String - Default = undefined

Your discord bot will see all messages sent in a server you invite it to. By default, it will only respond when you @ the bot. If name is set then the bot will instead respond to any message that begins with a string matching name. By default this is not case sensitive but you can set caseSensitiveName to true if you want the name to be case sensitive.

caseSensitiveName

Boolean - Default = false

Controls whether or not the bot name should be treated as if it is case sensitive. This field is ignored if name is not set.

missingCommandMessage

String|Function - Default = "The command you typed is not available 🙁"

See DiscordiaFramework.handleMissingCommand for more details.

The message to send if a server member tries to ask the bot to do an action it does not know how to handle. You can either customize the string or provide a function to give a more involved response.

help

String|Function - Default = @discordia/default-help

See DiscordiaFramework.handleHelp for more details.

The message to send if a server member tries to ask the bot for help. By default it will use @discordia/default-help to read your actions and send a response based on their accessors and descriptions. You can provide a static string as a response or provide a custom function to give a more involved response.

Testing

🚧 Coming Soon! 🚧

Keywords

FAQs

Package last updated on 07 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc